package com.cykj.page01;

/**
 * @BelongsProject: HandTomcat
 * @BelongsPackage: com.cykj
 * @Author: WWJ
 * @CreateTime: 2025-06-18 09:55
 * @Description: 实现runnable接口
 * @Version: 1.0
 */
public class MyRunnable implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            try {
                //阻塞 抛异常
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            //currentThread().getName()
            System.out.println(Thread.currentThread().getName() + " " + i);
        }

        //GGG
        System.out.println("死亡");
    }
    public static void main(String[] args) {
        //创建线程
        MyRunnable myRunnable = new MyRunnable();
        //就绪  myRunnable要基于thread实现
        new Thread(myRunnable).start();
        new Thread(myRunnable).start();
    }
}
